import mysql.connector

mydb = mysql.connector.connect(
    host="localhost",  # 数据库主机地址
    user="root",  # 数据库用户名
    passwd="ahj7789t" , # 数据库密码
    auth_plugin = 'mysql_native_password' # 身份验证插件
)

print(mydb)

mycursor = mydb.cursor()

mycursor.execute("SHOW DATABASES")

for x in mycursor:
    print(x)

mycursor.execute("SHOW DATABASES")